#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int N = 2010;


void solve()
{
    int n, k;
    cin >> n >> k;
    int l = 1, r = n;
    vector<int> ans(n);
    for(int i = 0; i < k; i++) {
        for(int j = i; j < n; j += k) {
            if(i % 2 == 0) {
                ans[j] = l;
                l++;
            }else{
                ans[j] = r;
                r--;
            }
        }
    }
    for(auto x : ans){
        cout << x << ' ';
    }
    cout << '\n';
}

int main()
{
    int t = 1;
    cin >> t;
    while (t--)
        solve();
    return 0;
}